package com.tjbklx1.pattern.singleton;

import org.junit.Test;

import com.tjbklx1.pattern.singleton.demo1.Emperor;
import com.tjbklx1.pattern.singleton.demo2.Singleton;
import com.tjbklx1.pattern.singleton.demo2.SingletonFactory;
import com.tjbklx1.pattern.singleton.demo3.MultiEmperor;
import com.tjbklx1.pattern.singleton.demo4.Book;

public class TestApp {

	@Test
	public void test1() {
		for (int i = 0; i < 10; i++) {
			Emperor.getInstance().say();
		}
		System.out.println("##########################");
	}

	@Test
	public void test2() {
		Singleton t = SingletonFactory.getInstance();
		t.doSomething();
	}

	@Test
	public void test3() {
		int minister = 10;
		for (int i = 0; i < minister; i++) {
			MultiEmperor e = MultiEmperor.getInstance();
			e.say();
		}
		System.out.println("########################");
	}

	@Test
	public void test4() {
		Book singleton1 = Book.getInstance();
		Book singleton2 = Book.getInstance();
		if (singleton1 == singleton2)
			System.out.println("same");
	}

}
